* 
* Paper: Think of the Children? The Effect of Children on Support for Welfare
* 
* AUthor: Saied Toossi
*
* Purpose: Code necessary to replicate tables and figures in the paper & supplementary
*		   materials. 
*
* Note: All data was collected independently by the author while at Syracuse  
*	    University through Lucid. Data collection took place in February and March 
*		of 2020.
*
********************************************************************************

* STEP 1: SET DIRECTORY AND LOAD DATA

cd ""

use "Think of the Children Data.dta", clear

* STEP 2: SET LOCALS

local controls1 fem_s hisp_s white_s black_s other_s highered_l young_s middle_s ///
				elderly_s lowinc_s midinc_s hiinc_s northeast_l midwest_l south_l ///
				west_l bornusa_s mar_s children_s emp_s socass_s dem_s rep_s ind_s ///
				lib_s con_s mod_s
			 
local controls2 fem_s hisp_s mideld_s highered_l midhiinc_s rep_s ind_s bornusa_s ///
		        mar_s children_s emp_s socass_s northeast_l midwest_l west_l
			 
local controls3 fem_s hisp_s white_s other_s mideld_s highered_l midhiinc_s bornusa_s ///
		        mar_s children_s emp_s socass_s northeast_l midwest_l west_l
			 
local controls4 fem_s hisp_s white_s other_s mideld_s highered_l midhiinc_s rep_s ///
		        ind_s northeast_l midwest_l west_l bornusa_s mar_s children_s emp_s ///
				socass_s
			 		 
local controls5 fem_l hisp_l white_l black_l other_l highered_l young_l middle_l ///
				elderly_l lowinc_l midinc_l hiinc_l dem_l rep_l ind_l northeast_l ///
				midwest_l south_l west_l
			 
local controls6 fem_l hisp_l white_l other_l mideld_l highered_l midhiinc_l rep_l ///
			    ind_l northeast_l midwest_l west_l attcheck
			 

* STEP 2: REPLICATE PAPER TABLES 

di "Table 1, Column 1"

sum `controls1' minutes if sample_3==1
	
di "Table 2, Column 1"

tab snap if sample_3==1 & c==1            // Panel A
tab snap if sample_3==1 & c==1 & dem_s==1 // Panel B
tab snap if sample_3==1 & c==1 & rep_s==1 // Panel C

di "Table 3, Column 1"

reg snap_i to_white_s tdi_white_s tbi_white_s twi_white_s ///
		   c_nonwhite_s to_nonwhite_s tdi_nonwhite_s tbi_nonwhite_s twi_nonwhite_s ///
		   `controls2' if sample_3==1
		   
test tbi_white_s=twi_white_s
test tbi_white_s=tdi_white_s

di "Table 3, Column 2"

reg snap_i to_black_s tdi_black_s tbi_black_s twi_black_s ///
		   c_nonblack_s to_nonblack_s tdi_nonblack_s tbi_nonblack_s twi_nonblack_s ///
		   `controls2' if sample_3==1

di "Table 3, Column 3"

reg snap_i to_rep_s tdi_rep_s tbi_rep_s twi_rep_s ///
           c_nonrep_s to_nonrep_s tdi_nonrep_s tbi_nonrep_s twi_nonrep_s ///
		   `controls3' if sample_3==1
		   
di "Table 3, Column 4"

reg snap_i to_dem_s tdi_dem_s tbi_dem_s twi_dem_s ///
		   c_nondem_s to_nondem_s tdi_nondem_s tbi_nondem_s twi_nondem_s ///
		   `controls3' if sample_3==1
		   
* STEP 3: REPLICATE PAPER FIGURES

di "Figure 2, Panel A"

reg snap_i anyt `controls4' if sample_3==1
		   
est sto anyt_snap_i 

coefplot (anyt_snap_i, color(gray) ciopts(recast(rcap) lcolor(black))), ///
		 vertical recast(bar) citop barwidt(0.2) ytitle("Percentage Points") ///
		 keep(anyt) yline(0, lcolor(black)) levels(95) ylabel(-5(2)17, grid glwidth(medium) ///
		 glcolor(black%20)) yscale(range(-5(2)17)) transform(* = @*100) ///
		 graphregion(color(white)) xtick(, grid glstyle(major))
		 
di "Figure 2, Panel B"

reg snap_i to tdi tbi twi `controls4' if sample_3==1
est sto t_snap_i
test tdi=tbi

coefplot (t_snap_i, color(gray) ciopts(recast(rcap) lcolor(black))), ///
		 vertical recast(bar) citop barwidt(0.2) ytitle("Percentage Points") ///
		 keep(to tdi tbi twi) yline(0, lcolor(black)) levels(95) ylabel(-5(2)17, grid glwidth(medium) ///
		 glcolor(black%20)) yscale(range(-5(2)17)) transform(* = @*100) ///
		 graphregion(color(white)) xtick(, grid glstyle(major))

* STEP 4: REPLICATE SUPPLEMENTARY MATERIALS

di "Table B1, Columns 1-5"

preserve

iebaltab `controls1' minutes if sample_3==1, grpvar(condition) control(1) browse ftest ///
		  save("")
		  
restore

di "Table D1-1"

foreach i in 0 1 {
	sum `controls5' if attcheck==`i' & sample_1==1
}

di "Table D1-2, Column 1"

reg snap_i to tdi tbi twi `controls6' if sample_1==1	

di "Table D1-2, Column 2"

reg snap_i to tdi tbi twi `controls4' if sample_4==1	

di "Table D2-1, Column 1"

reg snap_ir anyt `controls4' if sample_3==1           // Panel A	

reg snap_ir to tdi tbi twi `controls4' if sample_3==1 // Panel B

di "Table D2-1, Column 2"

reg snap_cc anyt `controls4' if sample_3==1           // Panel A

reg snap_cc to tdi tbi twi `controls4' if sample_3==1 // Panel B

di "Table D3-1, Columns 1 & 2"

gologit2 snap_o anyt `controls4' if sample_3==1 		   // Panel A
		
gologit2 snap_o to tdi tbi twi `controls4' if sample_3==1 // Panel B

di "Table D3, Column 3"

reg snap_i anyt if sample_3==1			 // Panel A

reg snap_i to tdi tbi twi if sample_3==1 // Panel B

di "Table D4-1, Columns 1-7"

foreach var in cali_i pharma_i komen_i amazon_i nyc_i walmart_i nfl_i { // Panel A
	reg `var' to tdi tbi twi `controls4' if sample_3==1
}

preserve

drop if (c==1 | to==1)

foreach var in cali_i pharma_i komen_i amazon_i nyc_i walmart_i nfl_i { // Panel B
	reg `var' tbi twi `controls4' if sample_3==1
}

restore	